﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using CommonLib;

namespace CommonTest {
    class Program {
        static void Main(string[] args) {
            testVectorClass();
        }

        private static void testVectorClass() {
            Vector3c vec, clone, copy;
            double accum = 5.0;
            double amp = 2.0;
            double div = 10.0;

            vec = new Vector3c();
            Debug.Assert(vec.x == 0.0 && vec.y == 0.0 && vec.z == 0.0);

            double[] data = { -1.0, 0.0, 1.0 };
            vec = new Vector3c(data[0], data[1], data[2]);
            Debug.Assert(vec.x == data[0] && vec.y == data[1] && vec.z == data[2]);

            clone = vec;
            clone.add(accum);
            Debug.Assert(clone.x == vec.x + accum && clone.y == vec.y + accum && clone.z == vec.z + accum);

            clone.sub(accum);
            Debug.Assert(clone.Equals(vec));

            clone = vec;
            clone.mul(amp);
            Debug.Assert(clone.x == vec.x * amp && clone.y == vec.y * amp && clone.z == vec.z * amp);

            clone = vec;
            clone.div(div);
            Debug.Assert(clone.x == vec.x / div && clone.y == vec.y / div && clone.z == vec.z / div);

            clone = new Vector3c(0.0, -2.0, 2.0);
            copy = new Vector3c(1.0, 2.0, 3.0);
            DoubleTester.Assert(Math.Sqrt(clone.dot(clone)), clone.norm());
            DoubleTester.Assert(clone.dot(copy), copy.dot(clone));

            clone = vec;
            clone.normalize();
            DoubleTester.Assert(clone.norm(), 1.0);
        }
    }
}
